<!--************************************************************************************************-->
<!-- < mainPage.php >                                                                               -->
<!-- Copyright (c) 2012-2013 San Yat-sun University School of Software                              -->
<!-- Founder : Xiaofen Huang                                                                        -->
<!-- Stu : 10389169                                                                                 -->
<!-- Destription : 主页上的最新图书点进来之后图书列表           -->
<!-- Version : 2.1                                                                                  -->
<!--************************************************************************************************-->


<!DOCTYPE html>

<?php
	include_once("header.php");
	//include_once("bottom.php");
	include_once("../manager/BookManager.php");
	include_once("../manager/DescriptionManager.php");
	
	$flag = 0;
	
	if (isset($_REQUEST['description'])){
		$flag = 1;
		$description = $_REQUEST['description'];
		$book_names = DescriptionManager::getInstance()->getNBooksByDescription($description, 5);
		$book_images = array();

		foreach($book_names as $book_name)
			$book_images[] = "..\images\books\\$book_name".".jpg";
	}
	else {
		//=================added by xiaoxin
		$book_images = BookManager::getInstance()->getBookImages(5);
		$book_names = BookManager::getInstance()->getBooknames(BookManager::getInstance()->getBooklist(5));
	}
?>
<html lang="zh-hk">
<head>

	<title>Tiny bOOk</title>
	
	<meta http-equiv="Content-Type" content="text/html charset=UTF-8">
	<meta name="contentType" value="text/html  charset=GBK">
	<meta name="description" content="在这里你可以看到最新发布的书籍，和好友共享对某本书的评论和笔记">
	<meta http-equiv="imagetoolbar" content="no">
	<meta name="viewport" content="width=1036">
	
	<link rel="stylesheet" type="text/css" href="../css/bookList.css">
	

</head>

<body>
	<div id="left"><!-- 显示图书列表-->
		<?php
		if ($flag == 1)
		{
		?>
			<p>书籍标签：<?=$description?></p>
		<?php
		}
		for($i = 0; $i < count($book_images); $i++)
		{
				$book_value = BookManager::getInstance()->getValueByBookname($book_names[$i]);
		?>
			<div class="books">
				<a href="bookPage.php?book_name=<?=$book_names[$i]?>" >
					<img src="<?=$book_images[$i]?>" />
				</a>
				<div class="intro">
					<span><a href="bookPage.php?book_name=<?=$book_names[$i]?>"><?=$book_names[$i]?></a></span>
					<p>作者：<?=$book_value['AuthorName']?>/翻译者：<?=$book_value['Translator']?>/
					   出版社：<?=$book_value['Publishing']?>/价格：<?=$book_value['Price']?>元<p>
					<pre>简介：<?=$book_value['ContentBrief']?><pre>
				</div>
			</div><!--end of book list-->
		<?php
		}
		?>
	</div><!--end of left-->
</body>
</html>